<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/7/23
 * Time: 13:13
 */

namespace App\Services;

use App\Models\Banner;

class IndexService extends BaseService
{

    public function getBanner(string $name)
    {
        $sql = Banner::query()->select(['name', 'path', 'url'])->where('status', 1);
        if ($name) {
            if ($list = $sql->where('city_name', 'like', '%' . trim($name) . '%')->where('type', 1)->get()->toArray()) {
            } else {
                $list = Banner::query()->select(['name', 'path', 'url'])->where('city_name', 'like', '%' . trim($name) . '%')->where('status', 1)->where('type', 0)->get();
            }
            return $list;
        }
        return $sql->where('type', 0)->get();
    }
}